pkgname=tbench
pkgver=git
pkgrel=1
url='https://git.samba.org/sahlberg/dbench'
arch=('i386' 'x86_64')
license=('GPL')
makedepends_debian_11=(libpopt-dev zlib1g-dev xsltproc samba-dev libsmbclient-dev rpcgen)
source=('https://git.samba.org/sahlberg/dbench.git')
md5sums=('SKIP')

build()
{
	cd $srcdir/dbench
	cp -a loadfiles/*.txt /usr/local/share/

	./autogen.sh || return
	./configure CFLAGS=$(pkg-config --cflags smbclient) || return
	# Fix libnfs.c:27:39: error: intptr_t undeclared (first use in this function); did you mean in_port_t?
	sed -i '/#include "nfs.h/a #include <stdint.h>' libnfs.c
	make dbench || return
	make tbench || return
	make tbench_srv || return
	make install
}

package()
{
	benchmark_path="${pkgdir}/lkp/benchmarks/${pkgname}"
	usr_path="${pkgdir}/usr"

	mkdir -p $benchmark_path
	mkdir -p $usr_path/local/bin
	mkdir -p $usr_path/local/share

	cd $srcdir/dbench
	cp -a dbench tbench tbench_srv $usr_path/local/bin
	cp -a /usr/local/share/*.txt $usr_path/local/share
	touch $benchmark_path/empty
}
